#pragma once
#include "Engine.h"

void Initialize()
{
	E_.EngineInit();
	E_RUN = true;
	SDL_EnableKeyRepeat(1000, 10);
	SDL_VERSION(&LibVer);
	cout << "Engine version: " << (int)EngineVer.major << "." << (int)EngineVer.minor << "." << (int)EngineVer.patch << endl;
	cout << "Libs version: " << (int)LibVer.major << "." << (int)LibVer.minor << "." << (int)LibVer.patch << endl;
}

void SetWindowTitle(string Title)
{
	SDL_WM_SetCaption(Title.c_str(), NULL);
}

void GetSystemEvent()
{
	while(SDL_PollEvent(&E_EV))
	{
		switch(E_EV.type)
		{
		case SDL_QUIT:
			E_RUN = false;
			break;
		}
	}
}

void Update()
{
	SDL_Flip(E_VP);
}

Uint32 TimeLeft()
{
	static Uint32 TimeNext = 0;
	static Uint32 TimeNow = SDL_GetTicks();

	if(TimeNext <= TimeNow)
	{
		TimeNext = TimeNow + TICK;
	}
	return (TimeNext - TimeNow);
}

bool SwitchBoolState(bool Ref)
{
	if(Ref == true)
		Ref = false;
	else
		Ref = true;
	return Ref;
}